<template>
    <Dropdown :trigger="trigger" transfer @on-click="todo($event)">
        <Button type="primary">
            {{title}}
            <Icon type="ios-arrow-down"></Icon>
        </Button>
        <DropdownMenu slot="list">
            <DropdownItem v-for="item in dropList" :disabled="item.disabled?item.disabled:false" :key="item.name" :name="item.name">{{item.name}}</DropdownItem>
        </DropdownMenu>
    </Dropdown>
</template>
<script>
export default {
  name:'dropDown',
  props:{
    title:{
      type:String,
      default:'下拉菜单',
    },
    dropList:{
      type:Array,
      default:[]
    },
    trigger:{
      type:String,
      default:'click'
    },
    function:{
      type:Object
    }
  },
  methods:{
    todo(e){
      this.dropList.forEach(item => {
        if(item.name===e){
          this.function[item.fn]();
        }
      });
    }
  }
}
</script>